require File.dirname(__FILE__) + '/../lib/fetch.rb'

require 'rubygems'
require 'bacon'

describe 'requiring Bio::PDB::Fetch' do
  it 'should mean that Bio::PBB responds to fetch' do
    Bio::PDB.respond_to?('fetch').should.equal true
  end
end

describe 'fetching existing pdb file' do
  
  id = '1GPA'
  
  it 'should not return nil' do
    Bio::PDB.fetch(id).should.not.be.nil
  end

  it 'should equal expected result' do
    expected = File.new(File.dirname(__FILE__) + '/1gpa.pdb').gets(nil)
    Bio::PDB.fetch(id).to_s.should.equal expected
  end
end

describe 'fetching non existing pdb file' do
  
  id = 'xxxx'

  it 'should not throw an error' do
    lambda { Bio::PDB.fetch(id) }.should.not.raise
  end

  it 'should return nil' do
    Bio::PDB.fetch(id).should.be.nil
  end

end
